import Vue from 'vue'
import Vuex from 'vuex'
// import {getAdminInfo} from '@/api/getData'

Vue.use(Vuex)

const state = {
  adminInfo: {
    avatar: 'default.jpg'
  },
  user_id: 1,
}

const mutations = {
  saveAdminInfo(state, adminInfo){
    state.adminInfo = adminInfo;
  }
}

const actions = {
  async getAdminData({commit}){
    try{
      // const res = await getAdminInfo({user_id: state.user_id})
      // if (res.status == 1) {
      //  commit('saveAdminInfo', res.data[0]);
      // }else{
      //  throw new Error(res)
      // }
    }catch(err){
      console.log('您尚未登陆或者session失效')
    }
  }
}

export default new Vuex.Store({
  state,
  actions,
  mutations
})
